package com.bookstore.controller;

import com.bookstore.dto.OrderDTO;
import com.bookstore.entity.Order;
import com.bookstore.service.AdminOrderService;
import com.bookstore.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/admin/orders")
public class AdminOrderController extends BaseController<Order, OrderDTO, Long> {

    @Autowired
    private OrderService orderService;
    
    public AdminOrderController(AdminOrderService adminOrderService) {
        super(adminOrderService);
    }

    @PutMapping("/{orderId}/status")
    public ResponseEntity<?> updateOrderStatus(
            @PathVariable Long orderId,
            @RequestBody Map<String, String> statusMap) {
        String status = statusMap.get("status");
        return orderService.updateOrderStatus(orderId, status);
    }
}